/**
* login logic (sso)
*/
import config from 'config';
import _debug from 'debug';

const debug = _debug('app:lib:wx_login:');

/**
* take _wechat_userinfo to match db rows
* check whether registered to register or logined
* if login success to redirect refer directly
* if register:
*   1. redirect to page wait user confirm provision
*   2. save userinfo to db
*/
export default function* () {
  debug('this._wechat_userinfo: ', this._wechat_userinfo);

  this.session._wechat_userinfo = this._wechat_userinfo;
  debug('session::: ', this.session);

  // TODO logic
  this.redirect(this.query.redirect_uri || '/404');
}
